package com.salim.summary.design.$1factory;

public class CarFactory {
    public Car getInstance(String type){
        if(type.equals("big")){
            return new BigCar();
        }else if(type.equals("small")){
            return new SmallCar();
        }else if(type.equals("elec")){
            return new ElectricCar();
        }
        return null;
    }
    public static void main(String[] args){
        CarFactory carFactory = new CarFactory();
        carFactory.getInstance("big").drive();
        carFactory.getInstance("small").drive();
        carFactory.getInstance("elec").drive();
    }
}

class BigCar implements Car{
    @Override
    public void drive() {
        System.out.println("big");
    }
}

class SmallCar implements Car{
    @Override
    public void drive() {
        System.out.println("small");
    }
}

class ElectricCar implements Car{
    @Override
    public void drive() {
        System.out.println("elec");
    }
}


